package ru.ncedu.java.vlku.hrs.bll.impl;

import ru.ncedu.java.vlku.hrs.bll.HRSManager;
import ru.ncedu.java.vlku.hrs.dal.dao.DataBaseDAO;
import ru.ncedu.java.vlku.hrs.model.*;
import ru.ncedu.java.vlku.hrs.dal.dao.DataBaseFactory;

import javax.management.BadAttributeValueExpException;
import java.util.List;

public class HRSManagerImpl implements HRSManager {
    private DataBaseDAO dao = DataBaseFactory.getInstance().getDataBaseDAO();

    public HRSManagerImpl() {
    }

    @Override
    public void createCustomerAccount(CustomerAccount ca) throws BadAttributeValueExpException {
        String pass = ca.getPassword();

        // Business logic! Uahahaha
        if (pass.length() < 4)
            throw new BadAttributeValueExpException("Unsafe password");
        dao.createCustomerAccount(ca);
    }

    @Override
    public void updateCustomerAccount(CustomerAccount ca) throws BadAttributeValueExpException {
        String pass = ca.getPassword();

        // Business logic! Uahahaha
        if (pass.length() < 4)
            throw new BadAttributeValueExpException("Unsafe password");
        dao.updateCustomerAccount(ca);
    }

    @Override
    public CustomerAccount getCustomerAccountById(Long id) {
        return dao.getCustomerAccountById(id);
    }

    @Override
    public List<CustomerAccount> getCustomerAccountsWithName( String name ) {
        return dao.getCustomerAccountsWithName(name);
    }
    @Override
    public List<CustomerAccount> getAllCustomerAccounts() {
        return dao.getAllCustomerAccounts();
    }

    @Override
    public void createShop(Shop shop) {
        dao.createShop(shop);
    }

    @Override
    public void updateShop(Shop shop) {
        dao.updateShop(shop);
    }

    @Override
    public Shop getShopById(Long id) {
        return dao.getShopById(id);
    }

    @Override
    public List<Shop> getShopsWithName(String name) {
        return dao.getShopsWithName(name);
    }

    @Override
    public List<Shop> getAllShops() {
        return dao.getAllShops();
    }

    @Override
    public void createStorage(Storage storage) {
        dao.createStorage(storage);
    }

    @Override
    public void updateStorage(Storage storage) {
        dao.updateStorage(storage);
    }

    @Override
    public Storage getStorageById(Long id) {
        return dao.getStorageById(id);
    }

    @Override
    public List<Storage> getStoragesWithName(String name) {
        return dao.getStoragesWithName(name);
    }

    @Override
    public List<Storage> getAllStorages() {
        return dao.getAllStorages();
    }

    @Override
    public void createBill(Bill bill) {
        dao.createBill(bill);
    }

    @Override
    public void updateBill(Bill bill) {
        dao.updateBill(bill);
    }

    @Override
    public Bill getBillById(Long id) {
        return dao.getBillById(id);
    }

    @Override
    public List<Bill> getAllBills() {
        return dao.getAllBills();
    }

    @Override
    public void createTariff(Tariff tariff) {
        dao.createTariff(tariff);
    }

    @Override
    public void updateTariff(Tariff tariff) {
        dao.updateTariff(tariff);
    }

    @Override
    public Tariff getTariffById(Long id) {
        return dao.getTariffById(id);
    }

    @Override
    public List<Tariff> getAllTariffs() {
        return dao.getAllTariffs();
    }

    @Override
    public void createCargo(Cargo cargo) {
        dao.createCargo(cargo);
    }

    @Override
    public void updateCargo(Cargo cargo) {
        dao.updateCargo(cargo);
    }

    @Override
    public Cargo getCargoById(Long id) {
        return dao.getCargoById(id);
    }

    @Override
    public List<Cargo> getCargosWithName(String name) {
        return dao.getCargosWithName(name);
    }

    @Override
    public List<Cargo> getAllCargos() {
        return dao.getAllCargos();
    }

    @Override
    public void createPrice(Price price) {
        dao.createPrice(price);
    }

    @Override
    public void updatePrice(Price price) {
        dao.updatePrice(price);
    }

    @Override
    public Price getPriceById(Long id) {
        return dao.getPriceById(id);
    }

    @Override
    public List<Price> getAllPrices() {
        return dao.getAllPrices();
    }

    @Override
    public void createBillCargo(BillCargo bc) {
        dao.createBillCargo(bc);
    }

    @Override
    public void updateBillCargo(BillCargo bc) {
        dao.updateBillCargo(bc);
    }

    @Override
    public BillCargo getBillCargoById(Long id) {
        return dao.getBillCargoById(id);
    }

    @Override
    public List<BillCargo> getAllBillCargos() {
        return dao.getAllBillCargos();
    }

    @Override
    public void createShopCargoAvailability(ShopCargoAvailability sca) {
        dao.createShopCargoAvailability(sca);
    }

    @Override
    public void updateShopCargoAvailability(ShopCargoAvailability sca) {
        dao.updateShopCargoAvailability(sca);
    }

    @Override
    public ShopCargoAvailability getShopCargoAvailabilityById(Long id) {
        return dao.getShopCargoAvailabilityById(id);
    }

    @Override
    public List<ShopCargoAvailability> getAllShopCargoAvailabilities() {
        return dao.getAllShopCargoAvailabilities();
    }

    @Override
    public void createStorCargoAvailability(StorCargoAvailability sca) {
        dao.createStorCargoAvailability(sca);
    }

    @Override
    public void updateStorCargoAvailability(StorCargoAvailability sca) {
        dao.updateStorCargoAvailability(sca);
    }

    @Override
    public StorCargoAvailability getStorCargoAvailabilityById(Long id) {
        return dao.getStorCargoAvailabilityById(id);
    }

    @Override
    public List<StorCargoAvailability> getAllStorCargoAvailabilities() {
        return dao.getAllStorCargoAvailabilities();
    }
}
